# koroFileHeader at Yungoal acer
# Create: 2021-06-09 14:50:27
# LastEdit: 2021-06-09 15:17:14
"""说明暂无"""
__author__ = '749B'

import sys
import io
import unittest

if __name__ == '__main__':
    import os
    sys.path.append(os.getcwd())
# pylint: disable = import-error
from utils.vault import encrypt, decrypt


class VaultTestCase(unittest.TestCase):

    @classmethod
    def setUpClass(cls) -> None:
        stdout = sys.stdout
        sys.stdout = io.StringIO()

        import this as _
        cls.the_zen_of_python = sys.stdout.getvalue()
        
        sys.stdout = stdout
    
    def test_the_zen_of_python(self):
        password = '123456'
        fmt_vaulttext = encrypt(self.the_zen_of_python, password)
        #print(f'密文:\n{fmt_vaulttext}')
        
        plaintext2 = decrypt(fmt_vaulttext, password)
        #print(f'明文:\n{plaintext}')
        
        self.assertMultiLineEqual(self.the_zen_of_python, plaintext2)

    def test_the_zen_of_python_from_vaulttext(self):
        fmt_vaulttext = """
            $YUNGOAL_VAULT:
            NzhlMzc0Nzc3MjBiNDFjYjliMWRjNWQxMzAzYmEzZDc3OWNmMGNhZWVlZDM4YmJhYTJjOWJmYWQx
            ODE0NTkwOQowZTRlODk0NzIxMTQwMWY1ZTJhZmM4NzI2MmQzZDQ5MjM1N2UwM2M0ZDFiYTJmYjcz
            Y2ExMzQ5MTM4MDA1ZDJmCmNhNzg5MGRjZTRkNDc1NjNhOWI4NmI0ZGIwZGYzYTgzMzIzZjY3MDI1
            YzdmMGZlZDI3ZDE3NGZmMGEyZDBiNzg4ZDJiY2RhZTY0MmRkZmQwNWUyYTdlMmJkNTEyNGUxMDQ5
            NjE5NjI4OThlYmQ1MjM5MGQwOTA3NjBlYmE2MjExNjUzNjMxOGRiYzM2OTI4MjBiNjc2MGZlNDJm
            YzhmNTk5N2E3MDdiYThhNWU5NmU5ZmZkYzIwMmY2MjVkNjAyY2JlNTAwMjYwZDU3NjE1NzBiZTU4
            MTgwYzBhNmYwNTExMGRjNjA5YTM2MTk0NzljMTZiM2M4ZmJlZDM0ZWExODNhMGM4MjFlOTM1MWM2
            MDJkY2RjYTE5NTc4MTBlYmEyYzRhZGM0YWMxNzI5ODIwM2FlMmVjZDQ0Yzc2OWY4ZmJkMjJhNTEz
            N2FhZmViYWRlYWViMDcwMDdhYWIxNGM2MGZiNWM4ZGU0OWYxOGQ2ZTI1ODcxM2ZkYWNmMzM3ZGYw
            Njk5MDlmZjMzNzExNDRjYTE2ZjhhZDQwOWZlOGM1ZWE0OGQ2OWQ3OTFhMDE0ZTA3NWNjOWEwNzFl
            ZmYxOTc3MGZmODBlNDk3MjcyOTc1NWFkNzQzODNkNjY0OTBkNTNlOGQ4YjdmZWM4MDNmMDVlZTg1
            NTAwODFiNTkwMGYzOTk0NDE1YWI1NTAwYWRiOGIxNWY5ZjBjY2Q5NjA1OTNkNjI3MTIxYTI2Nzcx
            MDQ4ODcyZTYwY2QyZTRjNzIwNDkzMDk0MDFhOGFkYjczNDdhODIyZTY4ZmE3MzI3ZmNkMDgxZDY1
            YWY0MWQ1YTZiN2NlODc3MjhmMjczYTk3OTA5NmZlNTJhMjhjYzA4N2ZlODJjNDgwNjdiMjA2NzIz
            Mzk3NDg0NTg5NjQ3NjY5MGQ3ZjliNDRkYzQ5MGEzNDZmZmY0YjZlZDA2OTY3NmMwZTM4MjZhNjJl
            NmE4OWE3YWRhYmEzZTA4NWI5ZjMwMzM5ZDM1MGU4YjcwZWVmMjBhMmQ3NDJkYmE5MDg4OGZlMDVj
            Nzc5YmQ4OTAwNjliMWM0YjlmYzEzYzQzOTJhYmY4NjdkZTEyNWNkMzYzZTQwOGI4MmZkYzgzYzhl
            OWNmNzU2YjI5MTgxYjE3NDk0MTdlZDJmNTgzZGYzYzg5ZTBhNjVmZGRiMWZhZTRlZDYxOGMwMzlh
            MjAzMTQ1YjgyODU1MjZlMjAzNzRiNjNhYTliNmRjNjc5NWM5NmIwOGMwMTkxMjE3M2Y1MzE3ZDY3
            NTYxYWYxNmNjZWIyNDI3ZWU0ZGY3YTA5NjU1ZTgwOGE5YmUwYjliNzU3ZjM4Mjk3NDlkMWQyM2Mx
            NDg5MjVjM2Q0NmRiNWE3M2ExNDUyNWUwZWE3NGZlZTk1MDg0MTJjOWU1ZDhlNjMzNzc3NTdjYzNk
            MTUzYzAwMDhjNmNiNDNmMGRjZjU1NzRmNjE3OTQ1MDA3Y2MyODQ3ZGFmNDg0MDBlM2JkYzY3YzRj
            YTQ5MzMwN2ZiNzg3ZTgyOGE2MDg0OWVlZDQzZDNmZDgyMmI0ZGY3OTUxZjk5YzhhNjM2NmVmNjFm
            Mzk3ZjE1MDYzYTliNjg3NzZmODUxMTJiMGQ4YTA0MjBiYjdhNzA5ZDVkZTlhZTcyYmVkYTcxYWY1
            MjI3OTZmMTVhMTFhNzQxMzI2YTkxNDJhZjdiMTI2MmNkZGNhN2EzZGZhZjFhMTgzMTNmNjUxMDcw
            NDI4NzQ0ZTEyYjBlOTk2MWFlOGY3NzU4MDUzNTk4N2U1YjIxMzY5MGFjN2RhNzQ3OWU4OGU2MDlh
            MmVmOGU1YmFjOWIyNjFkZmM4YTUyMThhODhiZmRjZmZjNjAyNDdhMGJmYjhhYzNlYmYxMTE5MDZh
            ZjEzYWNhZGEyNWE2YzA3OWNmZTljODJiMTU5MTMwNTg4ZDA4NDMxMzEyNzIwMWVjZmY4MDM0YzM5
            NzZlZjc0Y2U3NDM4ODgyZmFhMjI0ZGVhM2M1OWJhZjFhNTc5N2ZmMmI4NTc3ZjIxZTA1NzgyOGMx
            ODA3MjY5NzhjYmJhZjI3ZjIyMTZkOGI0ZjMyNDQ4ZGRiNGU3ZjQ0ZDE4ZWFiMTA0NTdkYzI2MDEx
            NGQyOTI5ZWUwYWE4ZWI2ODZiNmUwZWU3ZDcyMGViNTI1NzBhOTM4MzhmNjk3NTM2NGJiNzIzMTI3
            YjVmMmVhMDVlYmUzZWVlZTI3Y2Y3NjM4ZWM5OWRhMzE2YzI0YThhMjZlNGE0OTBmMmZjNTUzNTNi
            YjY0MGI2OGE1OGJiZGE3ZTFkNTIxZmNmMzBmODRlYzM4Yg==
            """
        plaintext = decrypt(fmt_vaulttext, '123456')
        self.assertMultiLineEqual(self.the_zen_of_python, plaintext)


if __name__ == '__main__':
    unittest.main()
